//
//  RepositoryViewController.m
//  TeacherPro
//
//  Created by DCQ on 2017/9/5.
//  Copyright © 2017年 ZNXZ. All rights reserved.
//

#import "RepositoryViewController.h"
#import "RepositoryListModel.h"
#import "RepositoryCell.h"
#import "PlainFlowLayout.h"
#import "RepositorySectionView.h"
#import "BookPreviewDetailViewController.h"
 
#import "RepositoryBannerCell.h"
#import "RepositoryTitleCell.h"
#import "RepositoryBookViewController.h"
#import "RepositoryCartoonViewController.h"
#import "RepositoryScreeningView.h"
#import "RepositoryEmptyCell.h"
#import "QueryBookFilterModel.h"
#import "RepostioryAssistantsViewController.h"
#import "BookSearchViewController.h"
#import "RepositoryBannerHeaderView.h"


NSString * const ReposityoryCellIdentifier = @"ReposityoryCellIdentifier";
NSString * const RepositoryBannerCellIdentifier = @"RepositoryBannerCellIdentifier";
NSString * const RepositorySectionViewIdentifier = @"RepositorySectionViewIdentifier";
NSString * const RepositoryTitleCellIdentifier = @"RepositoryTitleCellIdentifier";
NSString * const RepositoryEmptyCellIdentifier = @"RepositoryEmptyCellIdentifier";
#define   screeningHeaderHeight     80

typedef NS_ENUM(NSInteger,QueryBookFilterType){
    QueryBookFilterType_grade =  0,
    QueryBookFilterType_subjects ,
    QueryBookFilterType_types ,
    QueryBookFilterType_publishers ,
};
@interface RepositoryViewController ()<RepositoryScreeningViewDelegate>
@property(nonatomic, strong) RepositoryListModel * listModel;
@property(nonatomic, strong) RepositoryScreeningView *screeningView;
@property(nonatomic, strong) NSNumber * grade;
@property(nonatomic, copy) NSString * subjectId;
@property(nonatomic, copy) NSString * bookType;
@property(nonatomic, copy) NSString * publisherId;
@property(nonatomic, assign) NSInteger selectedScreeningtType;
@property(nonatomic, copy) NSString * selectedScreeningtName;
@property(nonatomic, assign) BOOL isScrollPosition;

@property(nonatomic, assign) NSInteger selectedGradeIndex;//年级
@property(nonatomic, assign) NSInteger selectedSubjuctsIndex;//科目
@property(nonatomic, assign) NSInteger selectedTypeIndex;//类型
@property(nonatomic, assign) NSInteger selectedVersionIndex;//版本
@property(nonatomic, strong) SubjectsModel *subjectsModel;
@property(nonatomic, strong) GradesModel  *gradesModel;
@property(nonatomic, strong) BookTypesModel *typesModel;
@property(nonatomic, strong) PublishersModel *publishersModel;
@property(nonatomic, assign) QueryBookFilterType  filterType;
@property(nonatomic, assign) BOOL  isHome;
@end

@implementation RepositoryViewController
- (instancetype)initWithFromHome:(BOOL)isHome{
    self = [super init];
    if(self){
        self.isHome = isHome;
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setNavigationItemTitle:@"资源库"];
    [self setupNavigatioBarRight];
    self.pageCount = 12;
    [self requestListBooks];
    [self.view addSubview:self.screeningView];
    self.selectedScreeningtType = -1;
//    [self configuraCollectionView];
    
    
}
- (void)configuraCollectionView{
    CGFloat imgH = 133;
    CGFloat  btnH = 60;
    CGFloat  bannerH = imgH+btnH;
    self.collectionView.contentInset = UIEdgeInsetsMake(bannerH, 0, 0, 0);
    RepositoryBannerHeaderView  * bannerHeader = [[NSBundle mainBundle ]loadNibNamed:NSStringFromClass([RepositoryBannerHeaderView class]) owner:nil options:nil].firstObject;
    [self.collectionView addSubview: bannerHeader];
    [bannerHeader mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.view.mas_left);
         make.bottom.mas_equalTo(self.collectionView.mas_top);
         make.right.mas_equalTo(self.view.mas_right);
         make.height.mas_equalTo(@(bannerH));
    }];
}

- (RepositoryScreeningView *)screeningView{
    
    if (!_screeningView) {
        _screeningView = [[RepositoryScreeningView alloc]initWithFrame:CGRectMake(0,screeningHeaderHeight, self.view.frame.size.width, self.view.frame.size.height-screeningHeaderHeight)  ];
        _screeningView.backgroundColor = [UIColor clearColor];
        _screeningView.delegate = self;
        _screeningView.hidden = YES;
        
    }
    return   _screeningView;
}
- (BOOL)isAddRefreshFooter{
    
    return YES;
}
- (void)registerCell{
    
    [self.collectionView registerNib:[UINib nibWithNibName:NSStringFromClass([RepositoryCell class]) bundle:nil] forCellWithReuseIdentifier:ReposityoryCellIdentifier];
    [self.collectionView registerNib:[UINib nibWithNibName:NSStringFromClass([RepositoryBannerCell class]) bundle:nil] forCellWithReuseIdentifier:RepositoryBannerCellIdentifier];
    
    [self.collectionView registerNib:[UINib nibWithNibName:NSStringFromClass([RepositorySectionView class]) bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:RepositorySectionViewIdentifier];
    [self.collectionView registerNib:[UINib nibWithNibName:NSStringFromClass([RepositoryTitleCell class]) bundle:nil] forCellWithReuseIdentifier:RepositoryTitleCellIdentifier];
    
    [self.collectionView registerNib:[UINib nibWithNibName:NSStringFromClass([RepositoryEmptyCell class]) bundle:nil] forCellWithReuseIdentifier:RepositoryEmptyCellIdentifier];
    
    
}

- (UICollectionViewLayout *)getCollectionViewLayout{
    UICollectionViewLayout * collectionViewLayout ;
    PlainFlowLayout * plainFlowLayout = [[PlainFlowLayout alloc]init];
    plainFlowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
    plainFlowLayout.naviHeight = 0.0f;
    collectionViewLayout = plainFlowLayout;
    
    return collectionViewLayout;
}
- (void)setupNavigatioBarRight{
    UIButton * searchBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [searchBtn setTitle:@"搜索" forState:UIControlStateNormal];
    [searchBtn setTitleColor:[UIColor grayColor] forState:UIControlStateHighlighted];
    [searchBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal ];
    [searchBtn addTarget:self action:@selector(rightAction:) forControlEvents:UIControlEventTouchUpInside];
    [searchBtn setFrame:CGRectMake(0, 5, 40,60)];
    searchBtn.titleLabel.font = fontSize_14;
    UIBarButtonItem * rightBar = [[UIBarButtonItem alloc]initWithCustomView:searchBtn];
    self.navigationItem.rightBarButtonItem = rightBar;
    
}

- (void)rightAction:(UIButton *)sender{
    
    [self gotoSearchBookVC];
}
- (void)getLoadMoreCollectionViewNetworkData{
   [self requestListBooks];
}

- (NSInteger )getNetworkCollectionViewDataCount{
    
    return [self.listModel.list count];
}
#pragma mark ---
- (void)requestListBooks{
    
    
    NSMutableDictionary * parameterDic =[NSMutableDictionary dictionary];
    [parameterDic addEntriesFromDictionary: @{@"pageIndex":@(self.currentPageNo),
                                              @"pageSize":@(self.pageCount)
                                              }];
    if (self.grade) {
        [parameterDic addEntriesFromDictionary: @{@"grade":self.grade,
                                                  
                                                  }];
        
    }
    if (self.subjectId) {
        [parameterDic addEntriesFromDictionary: @{@"subjectId":self.subjectId,
                                                  
                                                  }];
    }
    if (self.bookType) {
        [parameterDic addEntriesFromDictionary: @{@"bookType":self.bookType,
                                                  
                                                  }];
    }
    
    if (self.publisherId) {
        [parameterDic addEntriesFromDictionary: @{@"publisherId":self.publisherId,
                                                  
                                                  }];
    }
    [self sendHeaderRequest:[NetRequestAPIManager getRequestURLStr:NetRequestType_ListBooks] parameterDic:parameterDic requestMethodType:RequestMethodType_POST requestTag:NetRequestType_ListBooks];
    
}
- (void)requestQueryBookFilterDic{
    
    [self sendHeaderRequest:[NetRequestAPIManager getRequestURLStr:NetRequestType_QueryBookFilterDic] parameterDic:nil requestMethodType:RequestMethodType_POST requestTag:NetRequestType_QueryBookFilterDic];
    

    
}
//查询出版社
- (void)requestPublisherQueryBookFilterDic2{
    NSDictionary * parameterDic = nil;
    if (self.subjectId) {
       
       parameterDic = @{@"subjectId":self.subjectId};
    }
    
    [self sendHeaderRequest:[NetRequestAPIManager getRequestURLStr:NetRequestType_QueryBookFilterDic2] parameterDic:parameterDic requestMethodType:RequestMethodType_POST requestTag:NetRequestType_QueryBookFilterDic2];
}
- (void)setNetworkRequestStatusBlocks{
    
    WEAKSELF
    [self setNetSuccessBlock:^(NetRequest *request, id successInfoObj) {
        STRONGSELF
        if (request.tag == NetRequestType_ListBooks) {
            if (!strongSelf.listModel.list) {
                strongSelf.listModel = [[RepositoryListModel alloc]initWithDictionary:successInfoObj error:nil];
            }else{
                RepositoryListModel * tempModel  =  [[RepositoryListModel alloc]initWithDictionary:successInfoObj error:nil];
                
                [strongSelf.listModel.list addObjectsFromArray:tempModel.list];
                
            }
            
            strongSelf.currentPageNo ++;
            [strongSelf updateCollectionView];
            if (strongSelf.isScrollPosition) {
//                [strongSelf.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:2] atScrollPosition:UICollectionViewScrollPositionTop animated:YES];
            }
            strongSelf.collectionView.mj_footer.hidden = NO;
        }else if (request.tag == NetRequestType_QueryBookFilterDic){
        
            [strongSelf confitgFilterDic:successInfoObj];
        }else if (request.tag == NetRequestType_QueryBookFilterDic2){
            NSLog(@"%@---",successInfoObj);
            [strongSelf  confitgFilterDic2:successInfoObj];
        }
        
    }];
    
}

- (void)confitgFilterDic2:(NSDictionary *)successInfoObj{
 
    NSDictionary * publisherDic = @{@"publishers":successInfoObj[@"dics"]};
     self.publishersModel = [[PublishersModel alloc]initWithDictionary:publisherDic error:nil];
 
}


- (void)confitgFilterDic:(NSDictionary *)successInfoObj{
    
    self.publishersModel = [[PublishersModel alloc]initWithDictionary:successInfoObj error:nil];
    self.gradesModel = [[GradesModel alloc]initWithDictionary:successInfoObj error:nil];
    self.subjectsModel = [[SubjectsModel alloc]initWithDictionary:successInfoObj error:nil];
    self.typesModel = [[BookTypesModel alloc]initWithDictionary:successInfoObj error:nil];
    
    switch (self.filterType) {
        case QueryBookFilterType_publishers:
            [self versionViewShowState:YES];
            break;
        case QueryBookFilterType_subjects:
            [self subjectsViewShowState:YES];
            break;
        case QueryBookFilterType_types:
            [self typeViewShowState:YES];
            break;
        case QueryBookFilterType_grade:
            [self gradeViewShowState:YES];
            break;
            
        default:
            break;
    }
    
}
#pragma mark ---

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    
    NSInteger section = 3;
    return  section;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    NSInteger row = 0;
    if (section == 0) {
        row = 1;
    }else if(section == 1){
        row = 0;
    }else{
        if (self.listModel.list.count >0) {
            row = [self.listModel.list count];
        }else{
            row = 1;
        }
        
    }
    return row;
}


- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    UICollectionViewCell *cell = nil;
    if (indexPath.section == 0) {
        RepositoryBannerCell * tempcell =  [collectionView dequeueReusableCellWithReuseIdentifier:RepositoryBannerCellIdentifier forIndexPath:indexPath];
        [tempcell setupBanner];
        tempcell.bottomBlock = ^(RepositoryBannerBottomType type) {
            if (type == RepositoryBannerBottomType_book) {
                [self gotoBookVC];
            }else if (type == RepositoryBannerBottomType_cartoon){
                [self gotoCartoonVC];
            }else if (type == RepositoryBannerBottomType_assistants){
                [self gotoTeachingAssistantsVC];
            }
        };
        cell = tempcell;
    }else if(indexPath.section == 1) {
        RepositoryTitleCell * tempcell =  [collectionView dequeueReusableCellWithReuseIdentifier:RepositoryTitleCellIdentifier forIndexPath:indexPath];
        
        cell = tempcell;
    } else{
        if ([self.listModel.list count]  >0) {
            RepositoryCell * tempCell = [collectionView dequeueReusableCellWithReuseIdentifier:ReposityoryCellIdentifier forIndexPath:indexPath];
            [tempCell setupRepositoryInfo:self.listModel.list[indexPath.item]];
            cell  = tempCell;
        }else{
            RepositoryEmptyCell * tempCell = [collectionView dequeueReusableCellWithReuseIdentifier:RepositoryEmptyCellIdentifier forIndexPath:indexPath];
            
            cell  = tempCell;
            
        }
        
    }
    
    return cell;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    CGSize size = CGSizeZero;
    if (indexPath.section == 0) {
        CGFloat imgH = 133;
        CGFloat  btnH = 60;
        CGFloat bannerH =  btnH + imgH;
        size = CGSizeMake(IPHONE_WIDTH ,bannerH );
    }else if (indexPath.section == 1) {
        size = CGSizeMake(IPHONE_WIDTH , FITSCALE(35));
    }else{
        if (self.listModel.list.count > 0) {
            size = CGSizeMake((IPHONE_WIDTH - 5*4)/3,104 + 70 );
        }else{
            size = CGSizeMake(IPHONE_WIDTH, self.view.frame.size.height- screeningHeaderHeight);
        }
        
    }
    return size;
}
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
    UICollectionReusableView *headerView = nil;
    if([kind isEqualToString:UICollectionElementKindSectionHeader])
    {
        RepositorySectionView * sectionView  = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:RepositorySectionViewIdentifier forIndexPath:indexPath];
        sectionView.backgroundColor = [UIColor whiteColor];
        if (self.selectedScreeningtName) {
            [sectionView setupButtonTitle:self.selectedScreeningtName withType:self.selectedScreeningtType];
        }
        
        sectionView.chooseBlock = ^(RepostoryChooseType type,BOOL isOpen) {
            [self showTypeView:type withIsOpen:isOpen];
        };
        headerView  = sectionView;
        
    }
    return headerView;
}

- (void)showTypeView:(RepostoryChooseType )type withIsOpen:(BOOL)isOpen{
    [self contentOffsetCollectionView];
    if (type == RepostoryChooseType_gard) {
        self.filterType = QueryBookFilterType_grade;
        if (!self.gradesModel) {
            [self requestQueryBookFilterDic];
        }else{
            [self gradeViewShowState:isOpen];
        }
    }else if (type == RepostoryChooseType_type){
        self.filterType = QueryBookFilterType_types;
        if (!self.typesModel) {
            [self requestQueryBookFilterDic];
        }else{
            [self typeViewShowState:isOpen];
        }
        
    }else if (type == RepostoryChooseType_subjects){
        self.filterType = QueryBookFilterType_subjects;
        
        if (!self.subjectsModel) {
            [self requestQueryBookFilterDic];
        }else{
            [self subjectsViewShowState:isOpen];
        }
    }else if (type == RepostoryChooseType_version){
        self.filterType = QueryBookFilterType_publishers;
        
        if (!self.subjectsModel) {
            [self requestQueryBookFilterDic];
        }else{
            [self versionViewShowState:isOpen];
        }
    }
 
     
  
}

- (void)contentOffsetCollectionView{
    self.collectionView.mj_footer.hidden = YES;
    CGFloat imgH = 133;
    CGFloat  btnH = 60;
    CGFloat  bannerH = imgH+btnH +5;
    [self.collectionView setContentOffset:CGPointMake(0, bannerH) animated: NO] ;
    self.collectionView.scrollEnabled = NO;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section
{
    CGSize size = CGSizeZero;
    if (section <=1) {
        size = CGSizeZero;
    } else{
        size = (CGSize){IPHONE_WIDTH,screeningHeaderHeight};
    }
    return size;
}
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
    UIEdgeInsets insets  = UIEdgeInsetsZero;
    if (section <=1) {
        insets = UIEdgeInsetsZero;
    }else
        insets = UIEdgeInsetsMake(5, 5, 5, 5);
    return insets;
}

// 选中某item
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section ==2) {
        if ([self.listModel.list count]  >0){
            [self gotoBookPreviewDetailVC:indexPath];
        }
    }
    
}

- (void)gotoBookPreviewDetailVC:(NSIndexPath *)indexPath{
    
    RepositoryModel *model = self.listModel.list[indexPath.item];
    BOOL existsState = NO;
    if ([model.hasInBookShelf integerValue] == 1) {
        existsState = YES;
    }
    NSString * bookType = model.bookType;
    BookPreviewDetailViewController * detail;
    if (self.isHome) {
         detail = [[BookPreviewDetailViewController alloc]initWithFromHomeBookId:model.id withBookType:bookType withExistsBookcase:existsState];
    }else{
         detail = [[BookPreviewDetailViewController alloc]initWithBookId:model.id withBookType:bookType withExistsBookcase:existsState];
    }
  
    detail.indexPath = indexPath;
    detail.selectedBlock = ^(NSIndexPath *indexPath) {
        RepositoryModel *model = self.listModel.list[indexPath.item];
        model.hasInBookShelf = @(1);
        [self.collectionView reloadItemsAtIndexPaths:@[indexPath]];
    };
    [self pushViewController:detail];
}

- (void)gotoSearchBookVC{
    
  
    BookSearchViewController * searchBookVC = [[BookSearchViewController alloc]init];
    [self pushViewController:searchBookVC];
    
}



- (void)gradeViewShowState:(BOOL)isShow{
    
    if (isShow) {
        
        if (self.gradesModel ) {
            self.screeningView.screeningType = RepositoryScreeningType_grade;
            self.screeningView.gradesModel = self.gradesModel;
            self.screeningView.rows = [self.gradesModel.grades count]+1;
            self.screeningView.selectedIndex = self.selectedGradeIndex;
            [self.screeningView updateTableView];
            [self.screeningView showView];
        }
        
    }else{
        
        [self.screeningView hideView];
         self.collectionView.scrollEnabled = YES;
    }
    
}


- (void)subjectsViewShowState:(BOOL)isShow{
    
    if (isShow) {
        self.screeningView.screeningType = RepositoryScreeningType_subjects;
        self.screeningView.subjectsModel = self.subjectsModel;
        self.screeningView.rows = [self.subjectsModel.subjects count]+1;
        self.screeningView.selectedIndex = self.selectedSubjuctsIndex;
        [self.screeningView updateTableView];
        [self.screeningView showView];
    }else{
        
        [self.screeningView hideView];
         self.collectionView.scrollEnabled = YES;
    }
}

- (void)typeViewShowState:(BOOL)isShow{
    
    
    if (isShow) {
     if (self.typesModel) {
            self.screeningView.screeningType = RepositoryScreeningType_type;
            self.screeningView.rows = [self.typesModel.bookTypes count]+1;
            self.screeningView.typesModel = self.typesModel;
            self.screeningView.selectedIndex = self.selectedTypeIndex;
            [self.screeningView updateTableView];
            [self.screeningView showView];
        }
        
    }else{
        [self.screeningView hideView];
         self.collectionView.scrollEnabled = YES;
    }
}

- (void)versionViewShowState:(BOOL)isShow{
    
    if (isShow) {
        if (self.publishersModel) {
            self.screeningView.screeningType = RepositoryScreeningType_version;
            self.screeningView.rows = [self.publishersModel.publishers count] + 1;
            self.screeningView.publishersModel = self.publishersModel;
            self.screeningView.selectedIndex = self.selectedVersionIndex;
            self.screeningView.publisherId = self.publisherId;
            [self.screeningView updateTableView];
            [self.screeningView showView];
        }
        
    }else{
        [self.screeningView hideView];
        self.collectionView.scrollEnabled = YES;
    }
}

#pragma mark ---
- (void)selectedType:(RepositoryScreeningType)type withIndexItem:(id )item withIndex:(NSInteger)selectedIndex{
    self.isScrollPosition = YES;
    [self.screeningView hideView];
    self.collectionView.scrollEnabled = YES;
    NSString * name = @"";
    switch (type) {
        case RepositoryScreeningType_grade:
            if ([item isKindOfClass:[NSString class]]) {
                self.grade = nil;
                name =  item;
            }else{
                self.grade =  ((GradeModel *)item).grade;
                name = ((GradeModel *)item).gradeName;
            }
            self.selectedGradeIndex = selectedIndex;
          
            break;
        case RepositoryScreeningType_subjects:
            if ([item isKindOfClass:[NSString class]]) {
                self.subjectId = nil;
                name =  item;
            }else{
                self.subjectId =  ((SubjectModel *)item).subjectId;
                name = ((SubjectModel *)item).subjectName;
            }
            self.selectedSubjuctsIndex = selectedIndex;
            [self requestPublisherQueryBookFilterDic2];
            break;
        case RepositoryScreeningType_version:
            if ([item isKindOfClass:[NSString class]]) {
                self.publisherId = nil;
                name =  item;
            }else{
                self.publisherId = [NSString stringWithFormat:@"%@",((PublisherModel *)item).id];
                name = ((PublisherModel *)item).versionName;
            }
            self.selectedVersionIndex = selectedIndex;
            break;
        case RepositoryScreeningType_type:
            if ([item isKindOfClass:[NSString class]]) {
                self.bookType = nil;
                name =  item;
            }else{
                self.bookType = ((BookTypeModel *)item).bookType;
                name = ((BookTypeModel *)item).bookTypeName;
            }
            self.selectedTypeIndex = selectedIndex;
            break;
        default:
            break;
    }
    self.selectedScreeningtName = name;
    self.selectedScreeningtType = type;
    self.currentPageNo = 0;
    self.listModel = nil;
    [self requestListBooks];
    
}

- (void)hiddScreeningView{
    
      self.collectionView.scrollEnabled = YES;
}
- (void)gotoBookVC{
    RepositoryBookViewController * bookVC = [[RepositoryBookViewController alloc]init];
    bookVC.subjectsModel = self.subjectsModel;
    bookVC.publishersModel = self.publishersModel;
    bookVC.gradesModel = self.gradesModel;
    [self pushViewController:bookVC];
    
}

- (void)gotoTeachingAssistantsVC{
    
    RepostioryAssistantsViewController * assistantsVC = [[RepostioryAssistantsViewController alloc]init];
    assistantsVC.subjectsModel = self.subjectsModel;
 
    assistantsVC.gradesModel = self.gradesModel;
    [self pushViewController:assistantsVC];
}
- (void)gotoCartoonVC{
    
    RepositoryCartoonViewController * cartoonVC = [[RepositoryCartoonViewController alloc]init];
    [self pushViewController:cartoonVC];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end

